#include<stdio.h>
#include<stdlib.h>
#define ushort unsigned short
ushort elements[]={
	0xc800,0xe400,0x7200,0x3100,
	0x8c80,0x4e40,0x2720,0x1310,
	0x08c8,0x04e4,0x0272,0x0131,
	0x001c,0x004e,0x0027,0x0013
};
ushort *buffer,buffer_n=1000;

ushort get_grid()
{
	int n,i,grid=0;
	char buf[5];
	for(n=0;n<4;n++)
	{
		gets(buf);
		for(i=0;i<4;i++)
		{
			if(buf[i]=='w')
			{
				grid|=0x8000>>(n*4+i);
			}
		}
	}
	return grid;
}

unsigned int flip_mix(ushort eles[],int n)
{
	ushort mix=0;
	while(n--)
	{
		mix^=elements[eles[n]];
	}
	return mix;
}

void add_stack(ushort *stack,int n)
{
	int i,j;

	if(stack[n-1]<0xf)
	{
		stack[n-1]++;
		return;
	}
	else
	{
		for(i=n-1;i>=0;i--)
		{
			if(stack[i]<0xf-n+i)
			{
				stack[i]++;
				for(j=i+1;j<n;j++)
				{
					stack[j]=stack[j-1];
				}
				return;
			}
		}
	}
}

int match_grid(ushort grid,int n_element)
{
	int i;
	ushort g=0;
	ushort tag=0;
	ushort *stack=(ushort*)malloc(n_element*sizeof(ushort));
	if(!stack)return 0;
	for(i=0;i<n_element;i++)
		stack[i]=i;
	do
	{
		if(grid==flip_mix(stack,n_element))
			return 1;
		add_stack(stack,n_element);
	}while(stack[0]<=0xf-n_element+1);
	free(stack);
	return 0;
}

int main()
{
	unsigned int finish=0,i;
	
	ushort grid=get_grid();
	buffer=(ushort*)malloc(buffer_n*sizeof(ushort));

	for(i=1;!finish;)
	{
		finish=match_grid(grid,i++);
	}

	printf("%d",i-1);
	return 0;
}